public class HF_ClientWSContact{
  // This method is to Add Contact information in .Net application.
  @future (callout=true)
  public static void AddContact(set<Id> conset) {
      string outputresult;  
      List<Contact> ConList = new List<Contact>([select Id,Partner_Contact_ID__c,FirstName,Middle_Name__c,LastName,Preferred_Name__c,GenderCode__c,StatusCode__c,Name_Id__c,SuffixCode__c,Salutation_code__c from Contact where ID In: conset]); 
      WebServiceFinal4.BasicEndpoint s = new WebServiceFinal4.BasicEndpoint();
            for(contact con: conList){
                 system.debug('******'+con);
                 //Stores contact details in ContactWrapper
                 WebServiceFinal2.ContactWrapper c = new WebServiceFinal2.ContactWrapper();
                     c.DataOn=system.DateTime.Now();
                     c.FirstName=con.FirstName;
                     c.Gender=con.GenderCode__c;
                     c.LastName=con.LastName;
                     c.MiddleName=con.Middle_Name__c;
                     if(con.Name_Id__c!=null){
                     c.NameID=Integer.Valueof(con.Name_Id__c); }
                     c.PartnerContactID=con.Partner_Contact_ID__c;
                     c.PreferredName=con.Preferred_Name__c;
                     c.SfdcContactID=con.Id;   
                     c.Status=con.StatusCode__c;
                     c.Suffix=con.SuffixCode__c;
                     c.Title=con.Salutation_code__c;
                    
             try {
                    outputresult=s.AddContact(c);
                    system.debug('****'+outputresult);
                 }
            catch(Exception ex)
                {
                    system.debug('output from webservice: '+ex);       
                }
            }
  }
      
  @future (callout=true)
  public static void UpdateContact(set<Id> conset) {
  
          Set<Id> accId=new Set<Id>();
          Set<String> nameId=new Set<String>();
          string outputresult;  
          List<Contact> ConList = new List<Contact>([select Id,AccountId,Partner_Contact_ID__c,FirstName,Middle_Name__c,LastName,Preferred_Name__c,GenderCode__c,StatusCode__c,Name_Id__c,SuffixCode__c,Salutation_code__c from Contact where ID In: conset]); 
          for(contact con: conList){
                accId.add(con.AccountId);
                nameId.add(con.Name_Id__c);
          }
          List<Contact> ConListOld = new List<Contact>([select Id,AccountId,Name_Id__c from Contact where ID In: conset and AccountId IN: accId and Name_Id__c IN: nameId]); 
          WebServiceFinal4.BasicEndpoint s = new WebServiceFinal4.BasicEndpoint();
                for(contact con: conList){
                system.debug('******'+con);
                //Stores contact details in ContactWrapper
                WebServiceFinal2.ContactWrapper c = new WebServiceFinal2.ContactWrapper();
                     c.DataOn=system.DateTime.Now();
                     c.FirstName=con.FirstName;
                     c.Gender=con.GenderCode__c;
                     c.LastName=con.LastName;
                     c.MiddleName=con.Middle_Name__c;
                     if(con.Name_Id__c!=null){
                     c.NameID = Integer.Valueof(con.Name_Id__c); }
                     c.PartnerContactID=con.Partner_Contact_ID__c;
                     c.PreferredName=con.Preferred_Name__c;
                     c.SfdcContactID = con.Id;   
                     c.Status=con.StatusCode__c;
                     c.Suffix=con.SuffixCode__c;
                     c.Title=con.Salutation_code__c;
                try {
                        if(ConListOld!=null && ConListOld.size()>0){
                        	outputresult=s.UpdateContact(c);
                            system.debug('Call Webservice------->'+outputresult);
                        }
                    
                    }
                catch(Exception ex)
                    {
                         system.debug('output from webservice: '+ex);       
                    }
            }
    }
}